<style type="text/css">
</style>
<script type="text/javascript">
    $(document).ready(function () {
        $(".limitEdit").dialog("option", "buttons", [
            {
                text: '保存', click: function () {
                role_limit_save();
            }
            },
            {
                text: '取消', click: function () {
                $(this).dialog("close");
            }
            }
        ]);
        checkLimit();
    })
    function checkLimit() {
        for (var key in roleLimt) {
            for (var i = 0; i < roleLimt[key].length; i++) {
                $('input:checkbox[name=' + key + '][value=' + roleLimt[key][i] + ']').attr('checked', true);
            }
        }
    }
    function role_limit_save() {
        var d = {};
        $('.limitEdit input:checked').each(function (i, e) {
            if (d[$(this).attr('name')] == undefined)
                d[$(this).attr('name')] = [];
            d[$(this).attr('name')].push($(this).val());
        })
        d = JSON.stringify(d);
        var id = $('.roleDetail input[name=roleId]').val();
        $.ajax({
            url: 'system/role.action?act=update',
            type: 'POST',
            data: {'update.id': id, 'update.name': 'LIMIT', 'update.value': d},
            dataType: "JSON",
            success: function (rs) {
                if (rs.code == code.SUCCESS) {
                    $(".limitEdit").dialog('close');
                    LC.S.detail(id);
                } else {
                    alert(msg[rs.code]);
                }
            }
        });
    }
</script>
<#list limitConfig as p>
<fieldset class="package">
    <legend>${p.name}</legend>
    <ul>
        <#list p.action as a>
            <li><span class="limitName">${a.name}</span>
                <#list a.page as p>
                    <label><input type="checkbox" name="${a.key}" value="${p.value}"/>&nbsp;${p.name}</label>
                </#list>
            </li>
        </#list>
    </ul>
</fieldset>
</div>
</#list>